package cn.tinlan.shopcoin.Utils;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * Created by Mortimer on 2018/11/26. 16:56
 * 佛祖🙏，永无bug。
 */
public class RecordSQLiteOpenHelper extends SQLiteOpenHelper {

    private static RecordSQLiteOpenHelper sInstance;
    private static String name = "record.db";
    private static Integer version = 1;

    public RecordSQLiteOpenHelper(Context context) {
        super(context, name, null, version);
    }

    public static RecordSQLiteOpenHelper getInstance(Context context) {

        if (sInstance == null) {
            sInstance = new RecordSQLiteOpenHelper(context.getApplicationContext());
        }
        return sInstance;
    }
    @Override
    public void onCreate(SQLiteDatabase db) {
// 打开数据库 & 建立了一个叫records的表，里面只有一列name来存储历史记录：
        db.execSQL("create table records(id integer primary key autoincrement,name varchar(200))");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }

}
